 package com.gmrz.uaf.crypto.internal.handlers;
 
 import com.gmrz.uaf.crypto.spi.handlers.HashHandler;
 import org.apache.commons.codec.binary.Hex;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;

 import java.security.GeneralSecurityException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.security.Security;

 public class DefaultHashHandler
   implements HashHandler
 {
   private static final String HASH_ALGO = "SHA-256";
 
   public byte[] hash(byte[] data)
     throws GeneralSecurityException
   {
     MessageDigest digest = MessageDigest.getInstance(HASH_ALGO);
     if (digest != null) {
         // 使用指定的字节数组对摘要进行最后更新，然后完成摘要计算。
       return digest.digest(data);
     }
     return null;
   }

     public static void main(String args[]){

         try {
             //Security.addProvider(new BouncyCastleProvider());
             DefaultHashHandler hashHandler  = new DefaultHashHandler();
             String s = "hello";
             byte[] result = hashHandler.hash(s.getBytes());

         } catch (Exception e) {
             e.printStackTrace();
         }
     }
 }
